package com.trontria.simpledatamodel;

/**
 * 
 * @author TrungNQ
 */
public abstract class Model implements ModelDataInterface {
	
	/**
	 * 
	 * @return
	 */
	public abstract String getModelName();
	
	/**
	 * 
	 * @return
	 */
	public abstract Field[] fieldList();
	
	/**
	 * 
	 * @param fieldName
	 * @return
	 */
	public boolean hasField(String fieldName) {
		for (Field field : fieldList()) {
			if (field.name().equals(fieldName)) {
				return true;
			}
		}
		
		return false;
	}
	
	@Override
	public boolean equals(Object o) {
		if (o instanceof Model) {
			// Check if the 2 model classes have the same name, if so, they're 
			// the same
			return this.getModelName().equals(((Model) o).getModelName());
		} else {
			return false;
		}
	}
}